package com.study.bigwork.entity;


import java.util.ArrayList;
import java.util.List;

import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.GenericGenerator;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
@Entity
@Table(name="homework")
public class Homework {
	private int id;
	private int user_id;
	private String submitTime;
	private String deadline;
	private String homeworkType;
	private String tag;	
	private int teacher_id;
	private String result_text;
	private String scored;
	private String chatId;
	private int grade;
	
	private String homework_image1;
	private String result_image1;
	private String result_image_teacher1;
	private List<String> homework_image;
	private List<String> result_image;
	private List<String> result_image_teacher;
	
	
	
	@Override
	public String toString() {
		return "Homework [id=" + id + ", user_id=" + user_id + ", submitTime=" + submitTime + ", deadline=" + deadline
				+ ", homeworkType=" + homeworkType + ", tag=" + tag + ", teacher_id=" + teacher_id + ", result_text="
				+ result_text + ", scored=" + scored + ", chatId=" + chatId + ", grade=" + grade + ", homework_image1="
				+ homework_image1 + ", result_image1=" + result_image1 + ", result_image_teacher1="
				+ result_image_teacher1 + ", homework_image=" + homework_image + ", result_image=" + result_image
				+ ", result_image_teacher=" + result_image_teacher + "]";
	}
	public Homework() {
		super();
	}
	public Homework(int id, int user_id, String submitTime, String deadline, String homeworkType, String tag,
			int teacher_id, String result_text, String scored, String chatId, int grade, String homework_image1,
			String result_image1, String result_image_teacher1, List<String> homework_image, List<String> result_image,
			List<String> result_image_teacher) {
		super();
		this.id = id;
		this.user_id = user_id;
		this.submitTime = submitTime;
		this.deadline = deadline;
		this.homeworkType = homeworkType;
		this.tag = tag;
		this.teacher_id = teacher_id;
		this.result_text = result_text;
		this.scored = scored;
		this.chatId = chatId;
		this.grade = grade;
		this.homework_image1 = homework_image1;
		this.result_image1 = result_image1;
		this.result_image_teacher1 = result_image_teacher1;
		this.homework_image = homework_image;
		this.result_image = result_image;
		this.result_image_teacher = result_image_teacher;
	}
	
	@Id
	@GeneratedValue(generator="increment_generator")
	@GenericGenerator(name="increment_generator",strategy="increment")
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	@Column(name="scored")
	public String getScored() {
		return scored;
	}
	public void setScored(String scored) {
		this.scored = scored;
	}
	@Column(name="chatId")
	public String getChatId() {
		return chatId;
	}
	public void setChatId(String chatId) {
		this.chatId = chatId;
	}
	@Column(name="grade")
	public int getGrade() {
		return grade;
	}
	public void setGrade(int grade) {
		this.grade = grade;
	}
	@Column(name="user_id")
	public int getUser_id() {
		return user_id;
	}
	public void setUser_id(int user_id) {
		this.user_id = user_id;
	}
	@Column(name="submitTime")
	public String getSubmitTime() {
		return submitTime;
	}
	public void setSubmitTime(String submitTime) {
		this.submitTime = submitTime;
	}
	@Column(name="deadline")
	public String getDeadline() {
		return deadline;
	}
	public void setDeadline(String deadline) {
		this.deadline = deadline;
	}
	@Column(name="homeworkType")
	public String getHomeworkType() {
		return homeworkType;
	}
	public void setHomeworkType(String homeworkType) {
		this.homeworkType = homeworkType;
	}
	@Column(name="tag")
	public String getTag() {
		return tag;
	}
	public void setTag(String tag) {
		this.tag = tag;
	}


	@Column(name="teacher_id")
	public int getTeacher_id() {
		return teacher_id;
	}
	
	public void setTeacher_id(int teacher_id) {
		this.teacher_id = teacher_id;
	}
	
	
	@Column(name="result_text")
	public String getResult_text() {
		return result_text;
	}
	public void setResult_text(String result_text) {
		this.result_text = result_text;
	}
	
	
	@Column(name="homework_image")
	public String getHomework_image1() {
		return homework_image1;
	}
	public void setHomework_image1(String homework_image1) {
		this.homework_image1 = homework_image1;
	}
	@Column(name="result_image")
	public String getResult_image1() {
		return result_image1;
	}
	public void setResult_image1(String result_image1) {
		this.result_image1 = result_image1;
	}
	@Column(name="result_image_teacher")
	public String getResult_image_teacher1() {
		return result_image_teacher1;
	}
	public void setResult_image_teacher1(String result_image_teacher1) {
		this.result_image_teacher1 = result_image_teacher1;
	}
	@Transient
	public List<String> getHomework_image() {
		return homework_image;
	}
	public void setHomework_image() {
		System.out.println("homework_image:"+homework_image1);
		Gson gson=new Gson();
		List<String> list=gson.fromJson(this.homework_image1, new TypeToken<ArrayList<String>>() {
		}.getType());
		this.homework_image = list;
	}
	@Transient
	public List<String> getResult_image() {
		return result_image;
	}
	public void setResult_image() {
		System.out.println("result_image:"+result_image1);
		Gson gson=new Gson();
		List<String> list=gson.fromJson(result_image1, new TypeToken<ArrayList<String>>() {
		}.getType());
		this.result_image = list;
		
	}
	@Transient
	public List<String> getResult_image_teacher() {
		return result_image_teacher;
	}
	public void setResult_image_teacher() {
		System.out.println("result_image_teacher:"+result_image_teacher);
		Gson gson=new Gson();
		List<String> list=gson.fromJson(result_image_teacher1, new TypeToken<ArrayList<String>>() {
		}.getType());
		this.result_image_teacher = list;
	}
	
	
	



	
}
